<template>
	<div class="inceter_right">
		<aMian></aMian>
		<aTab :tabNac="tabNac" :static="static" @tabNacCiick="tabNacCiick"></aTab>
		<aList ref="getCamp"></aList>
	</div>
</template>

<script>
	export default {
		data(){
			return {
				static: 0 ,
				tabNac:[]
			}
		},
		mounted() {
			this.ksList()
			if(this.$route.query.static){
				this.static = this.$route.query.static
			}
		},
		watch:{
			$route (to, from) {
				// console.log('to.path----',to)//跳转后路由
				// console.log('from----',from)//跳转前路由
				var that = this
				if(to){
					localStorage.setItem('tagId',to.query.id)
					that.$store.state.print.tagId = to.query.id
					that.static = to.query.static
					that.$refs['getCamp'].getCampusList()
				} else {
					localStorage.setItem('tagId',from.query.id)
					that.$refs['getCamp'].getCampusList()
					that.$store.state.print.tagId = from.query.id
				}
				console.log('from----',that.$store.state.print.tagId)//跳转前路由
			},
		},
		beforeDestroy() {
			this.$store.state.print.urlName = ''
			this.$store.state.print.ksName = ''
      this.$store.state.print.tagId = ''
		},
		methods:{
			tabNacCiick(i,item){
				this.static = i
				localStorage.setItem('tagId',item.id)
				this.$store.state.print.tagId = item.id
				this.$store.state.print.ksName = item.name

				console.log('ksName',item)
				this.$refs['getCamp'].getCampusList()
			},
			ksList(){
				var that = this
				var data = {
					categoryId:that.$tab.Tablist(that.$route.name)
				}
				that.$api.TagsGetList(data).then(res => {
					if(res.code == 200) {
						that.tabNac = res.data
						console.log('222',res.data.sort())
            this.$store.state.print.tagId = res.data[0].id
						this.$store.state.print.ksName = that.tabNac[0].name
						that.$refs['getCamp'].getCampusList()
					}
				})
			},
		}
	}
</script>

<style>

</style>
